#ifndef TIMER_H
#define TIMER_H

#ifdef __GNUC__
#else
#include<windows.h>
#endif

#include<iostream>

#ifdef __GNUC__
class Timer{

public:
	int do_start_timer(){
		clock_gettime(CLOCK_REALTIME, &time1);
		return 0;
	}

	int do_end_timer(std::string prefix){
		clock_gettime(CLOCK_REALTIME, &time2);
		std::cout << prefix << (time2.tv_sec - time1.tv_sec)*1000.0 + (time2.tv_nsec - time1.tv_nsec) / 1000000.0 << "ms ####" << std::endl;
		return 0;
	}

private:
	struct timespec time1;
	struct timespec time2;

};

#else

class Timer{

public:
	Timer(){
		QueryPerformanceFrequency(&tc);
	}

	int do_start_timer(){
		QueryPerformanceCounter(&t1);
		return 0;
	}

	int do_end_timer(std::string prefix){
		QueryPerformanceCounter(&t2);
		std::cout << prefix << (t2.QuadPart - t1.QuadPart)*1000.0 / tc.QuadPart << "ms ####" << std::endl;
		return (t2.QuadPart - t1.QuadPart)*1000.0 / tc.QuadPart;
	}

private:
	LARGE_INTEGER t1;
	LARGE_INTEGER t2;
	LARGE_INTEGER tc;
};

#endif

#endif